const cloud = require('wx-server-sdk')
const db = cloud.database()

exports.main = async (event,context)=>{
	if(event.method == 'post'){
		await db.collection('base_info').add({
			data:event.data
		});
		return {'msg':'ok','data':result};
	}else{
		let result = await db.collection('base_info').get();
		let datas = result.data;
		new_datas = datas.map(function(item){
			let conss = null;
			try{
			conss = unescape(atob(item['biography']).replace(/\u/g, "%u")).replace(/\\/g,"");
			item['biography'] = conss;
			}catch(e){
				item['biography'] = e
			}
			return item
		})
		return {'msg':'ok','data':new_datas};
	}
}